const pinoHttp = require('pino-http');
const multiStream = require('./logConfig.js');
const pino = require('pino');

// 创建htpp日志实例

const logger = pino({
  name: 'http_logs',
  redact: ['req.params.password'],
  level: 'trace',
  timestamp: () => `,"time": "${new Date(Date.now()).toLocaleString()}"`,
  formatters: {
    level: (label) => {
      return {
        level: label
      }
    }
  }
}, multiStream); 


//  日志中间件
const httpLogger = pinoHttp({
  logger: logger,
  autoLogging:false
})

module.exports = httpLogger;